package api

import (
	"github.com/gin-gonic/gin"
	"three/api/handler"
	"three/api/middleware"
	"three/consts"
	jwt "three/pkg"
)

func LoadRouter(r *gin.Engine) {
	r.Use(middleware.RunTime())
	api := r.Group("/api")
	{
		user := api.Group("/user")
		{
			user.POST("/login", handler.Login)
		}
		room := api.Group("/room")
		{
			r.Use(jwt.JWTAuth(consts.JWT_SECRET_KET))
			room.POST("/add", handler.AddRoom)
			room.POST("/update", handler.UpdateRoom)
		}
		live := api.Group("/live")
		{
			live.POST("/add", handler.AddLive)
			live.POST("/find", handler.FindLive)
			live.POST("/update", handler.UpdateLive)
		}
	}
}
